<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php if(isset($pageTitle)) echo $pageTitle;?></title>
<base href="<?php echo base_url();?>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<?php echo base_url();?>template/admin/default/css/public.css" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url();?>template/admin/default/css/login.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo base_url();?>template/admin/default/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>template/admin/default/js/psufool.js"></script>
</head>
<script type="text/javascript">
isTop();
</script>
<body>
	<table cellpadding="0" cellspacing="1" border="0" class="login-container">
    	<form name="loginForm" id="loginForm" method="post" action="<?php echo site_url('admin/login');?>" target="_top">
    	<tr>
        	<td class="guid">用户名：</td>
            <td><input type="text" name="userName" id="userName" class="inputTxt" /></td>
        </tr>
    	<tr>
        	<td class="guid">密　码：</td>
            <td><input type="password" name="password" id="password" class="inputTxt" /></td>
        </tr>
    	<tr>
        	<td class="guid">验证码：</td>
            <td>
            	<table cellpadding="0" cellspacing="0" border="0" width="100%">
                	<tr>
                    	<td width="40%"><input type="text" name="chkCode" id="chkCode" class="inputTxt" /></td>
                        <td><span id="codeStr" class="pointer">单击获取验证码！</span></td>
                  </tr>
                </table>
            </td>
        </tr>
        </form>
    </table>
</body>
</html>
<script type="text/javascript">
var dg = frameElement.lhgDG;
$(function(){
	dg.addBtn('login','登 陆',loginSub);
	dg.addBtn('goHomePage','返回首页',goHomePage);
	$(document).bind('contextmenu',function(){return false;}).bind('selectstart',function(){return;});
	var codeStr = "单击获取验证码！";
	$("input[name='chkCode']").focus(function(){
		$(this).val("");
		var objCode = $("#codeStr");
		if(objCode.html()==codeStr){
			getCode();
		}
	});
	$("#userName").focus();
	$("#codeStr").click(getCode);
	$("body").bind('keydown',function(e){
		var key = e.which;
		if(key==13){
			loginSub();
		}
	});
});

var loginSub = function(){
	if($("#userName").val().length==0){
		subMess(208,108,'登陆错误','<span class="red">对不起，请输入用户名！</span>',$("#userName"));
		return false;
	}
	if($("#password").val().length==0){
		$("#password").focus();
		subMess(196,108,'登陆错误','<span class="red">对不起，请输入密码！</span>',$("#password"));
		return false;
	}
	if($("#chkCode").val().length==0){
		subMess(220,108,'登陆错误','<span class="red">对不起，请输入右侧的验证码！</span>',$("#chkCode"));
		return false;
	}
	$('#loginForm').submit();
}

var goHomePage = function(){
	gotoLocation('/','_top');
}

var getCode = function() {
		var codeFile = "";
		codeFile = "<?php echo site_url('admin/getcode')?>";
		$("#codeStr").html('<img src="' + codeFile + '?t=' + Math.random() + '" alt="点击刷新验证码" title="点击刷新验证码" onclick="this.src=\'' + codeFile + '?t=\'+Math.random()" valign=\'absmiddle\' />');
		$('#chkCode').focus();
};

var subMess = function(dialogWidth,dialogHeight,dialogTitle,dialogContent,focuseObj){
	var subMessDialog = new dg.curWin.$.dialog({		
			id:'subMess',
			width:dialogWidth,
			height:dialogHeight,
			parent:dg,
			cover: true,
			iconTitle:false,
			xButton:false,
			resize:false,
			rang:true,
			maxBtn:false,
			autoPos:{left:'center',top:'center'},
			cancelBtnTxt:'确定',
			onCancel:function(){
				focuseObj.focus();
			},
			title:dialogTitle,
			html:'<p class="mess-detail">' + dialogContent + '</p>'
	});
	subMessDialog.ShowDialog();
}
</script>